package cn.lyq.card.ui.order

import android.content.Context
import android.content.Intent
import cn.lyq.card.R
import cn.lyq.card.base.BaseActivity
import cn.lyq.card.data.model.OrderDetailInfo
import kotlinx.android.synthetic.main.act_order_pay_success.*


class OrderPaySuccessActivity : BaseActivity() {

    private val mInfo by lazy {
        intent.getSerializableExtra(KEY_INFO)
            ?.takeIf { it is OrderDetailInfo }
            ?.run { this as OrderDetailInfo }
    }

    companion object {
        private const val KEY_INFO = "INFO"

        @JvmStatic
        fun start(context: Context, info: OrderDetailInfo) {
            val starter = Intent(context, OrderPaySuccessActivity::class.java)
                .putExtra(KEY_INFO, info)
            context.startActivity(starter)
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.act_order_pay_success
    }

    override fun initView() {
        super.initView()
        setMyTitle(R.string.str_pay_success)

        mInfo?.let {
            tvOrderNo.text = it.orderNumber ?: ""
            tvOrderDate.text = it.payTime ?: ""
        }
    }
}